<template>
	<view class="content">
		<form @submit="formSubmit" @reset="formReset">
			<view>
			<view class="title">用户名</view>
			<input class="uni-input" name="username" placeholder="这是一个输入框" />
			</view>
			<view>
			<view class="title">密码</view>
			<input class="uni-input" name="password" placeholder="这是一个输入框" />
			</view>
			<view class="uni-btn-v">
				<button form-type="submit">Submit</button>
				<button type="default" form-type="reset">Reset</button>
			</view>
		</form>
	</view>
</template>

<script>
	  export default {
	        data() {
	            return {
	            }
	        },
	        methods: {
	            formSubmit: function(e) {
	                console.log('form发生了submit事件，携带数据为：' + JSON.stringify(e.detail.value))
	                var formdata = e.detail.value
					this.$request('/u/registOrLogin', {
						'username':formdata.username,
						'password':formdata.password
					},'POST').then(res => {		if(res.status === 200){
			uni.showToast({
				title:"登录成功"
			})
			uni.redirectTo({
			    url: '../home/home',
			});
			uni.setStorage({
			    key: 'username',
			    data: res.data.username,
			    success: function () {
			        console.log('success');
			    }
			});
			uni.setStorage({
			    key: 'faceImage',
			    data: this.$imgServerUrl+res.data.faceImage,
			    success: function () {
			        console.log('success');
			    }
			});

			
			
		}		console.log(res)		})
	                
	            },
	            formReset: function(e) {
	                console.log('清空数据')
	            }
	        }
	    }
</script>

<style>
</style>
